#ifndef _ephcheck_h_
#define _ephcheck_h_
#endif


//#include<stdio.h>
//#include<iostream>
#include "datatype.h"


#define D25bitpos  0x40EC7CD2  //0100 0000 1110 1100 0111 1100 1101 0010

#define D26bitpos  0x80763E69 // 1000 0000 0111 0110 0011 1110 0110 1001
#define D27bitpos  0x40BB1F34
#define D28bitpos  0x805D8F9A
#define D29bitpos  0x80AEC7CD
#define D30bitpos  0x402DEA27



#define Data30Xor  0x3fffffC0
#define WordBitSize 30   //30bit
#define SecDay			86400
#define SecWeek			604800
#define HalfWeek		302400

#define GpsPrnNum 36
#define BD2PrnNum 48

#define CONST_F -4.442807633e-10
//#define WGS_GRAPARA 3.986004418e14
#define WGS_GRAPARA 3.986005e14
#define WGS_ROTATEVEL 7.2921151467e-5
#define CGS_GRAPARA 3.986004418e14
#define CGS_ROTATEVEL 7.2921150e-5
#define CGS_COS_N5 0.99619469809174553229501040247389
#define CGS_SIN_N5 -0.08715574274765817355806427083747
#define WGS_C 2.99792458e8

struct StructSOW check_timer_data(struct StructSOW A);
struct StructSOW substract_timer(struct StructSOW A, struct StructSOW B);
double substract_timer_double(struct StructSOW A, struct StructSOW B);
struct StructSOW add_timer(struct StructSOW A, struct StructSOW B);
struct StructSOW format_timer(double A);
struct StructSOW format_timer_msps(long ms, long ps);
double  checktime(double time);
void MatrixMult(double* p_result, double* p_Matrix1, double* p_Matrix2, int R_M1, int C_M1, int R_M2, int C_M2);     // CM1 == RM2
void MatrixAdd(double* p_result, double* p_Matrix1, double* p_Matrix2, int R, int C);





bool Gpsparitycheckword(Uint32 word,Uint8 D29star,Uint8 D30star);
int  GpsXors(Uint32  word);
long    Gps_LNAV_Eph(unsigned long *word, struct StructGpsEphmeris_LNav *p_TmpEphmeris, struct StructGpsEphmeris_LNav *p_Ephmeris);
long    BD2_Eph_D1(unsigned long *word, struct StructBD2Ephmeris *p_TmpEphmeris, struct StructBD2Ephmeris *p_Ephmeris);
long	BD2_Eph_D2(unsigned long *word, struct StructBD2Ephmeris *p_TmpEphmeris, struct StructBD2Ephmeris *p_Ephmeris);
long GpsLNAVAlmDisassemble(unsigned long *word, struct StructGpsAlmData *GpsAlm, unsigned char idofsubframe);

void    GPSMeanAnomaly_LNAV(int prnnum);
void    SVpos_GPS_LNAV(int prnnum);
void    SVpos_BD2(int prnnum);